import { WebSocketUtil } from 'legions/socket';
import { IDirective, ProjectModules } from '../interface/project';
import { HttpConfig } from '../constants/httpConfig';
/* const SocketUrl = `${
  HttpConfig.domainLubanApi
}/socket/directive`;  */// 初始化连接
const SocketUrl=`${process.env.environment === 'dev'?'http://127.0.0.1:7013':'https://cicd.hoolinks.com'}/socket/directive`;
WebSocketUtil.registerInstanceWebSocket(SocketUrl);
/**
 * 指令执行结果接收
 *
 * @export
 * @param {*} success
 */
export function directiveReceive(
  success: (
    prams: IDirective['initProject'] | IDirective['generatedCode']
  ) => void
) {
  WebSocketUtil.receiveMessage(
    SocketUrl,
    (result: IDirective['initProject'] | IDirective['generatedCode']) => {
      success && success(result);
    }
  );
}
export function directiveSend(directive: IDirective) {
  WebSocketUtil.sendMessage(SocketUrl, directive);
}
